//反转链表 -- 递归练习

class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        if(head == nullptr || head->next == nullptr) return head;
        ListNode* ret = reverseList(head -> next);
        head->next->next = head;
        head->next = nullptr;
        return ret;
    }
};